package com.macro.mall.controller.show;

import com.macro.mall.common.api.ReturnObject;
import com.macro.mall.dto.SendSmsReq;
import com.macro.mall.dto.WxPhoneLoginReq;
import com.macro.mall.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * MinIO对象存储管理Controller
 * Created by macro on 2019/12/25.
 */
@RestController
@Api(tags = "ShowLoginController")
@Tag(name = "ShowLoginController", description = "前台登录控制层")
@RequestMapping("/show/login")
public class LoginController {

    @Resource
    private LoginService loginService;

    @ApiOperation("发送验证码")
    @PostMapping(value = "/send_sms")
    public ReturnObject<Void> sendSms(@Valid @RequestBody SendSmsReq req) {
        loginService.sendSms(req);
        return new ReturnObject<>();
    }

    @ApiOperation("手机号登录")
    @PostMapping(value = "/phone")
    public ReturnObject<String> upload(@Valid @RequestBody WxPhoneLoginReq req) {
       return new ReturnObject<>(loginService.phoneLogin(req));
    }

//    @ApiOperation("手机号登录")
//    @PostMapping(value = "/oneClick")
//    public ReturnObject upload() {
//
//
//
//    }

}
